package com.dkha.common.util;

/**
 * 身份证号，姓名屏蔽
 */
public class ShieldUtil {

    /**
     * 少数名字屏蔽·后
     * @param name
     * @return
     */
    public static String getShieldName(String name) {

        if (name != null && name.contains("·")) {
            String[] strings = name.split("·");
            char[] c = strings[1].toCharArray();
            for (int i = 0; i < strings[1].toCharArray().length; i++) {
                c[i] = '*';
            }

            strings[1] = new String(c);
            name = strings[0] + "·" + strings[1];
        }
        return name;

    }

    /**
     * 身份证号屏蔽出生日期
     * @param idCardNo
     * @return
     */
    public static String getShieldIdCardNo(String idCardNo) {
        if (idCardNo != null && idCardNo.trim().length() != 0) {
            char[] c = idCardNo.toCharArray();
            for (int i = 0; i < c.length; i++) {
                switch (i) {
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                    case 10:
                    case 11:
                    case 12:
                    case 13:
                        c[i] = '*';
                        break;
                }
            }
            idCardNo = new String(c);
        }
        return idCardNo;
    }

}
